package com.alvis.media.service.impl;

import com.alvis.media.domain.VideoInfo;
import com.alvis.media.repository.VideoInfoMapper;
import com.alvis.media.service.IVideoInfoService;
import com.alvis.media.viewmodel.video.VideoPageRequestVM;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class VideoServiceImpl extends BaseServiceImpl<VideoInfo> implements IVideoInfoService {

    private final VideoInfoMapper videoInfoMapper;

    @Autowired
    public VideoServiceImpl(VideoInfoMapper videoInfoMapper) {
        super(videoInfoMapper);
        this.videoInfoMapper = videoInfoMapper;
    }


    @Override
    public PageInfo<VideoInfo> findVideoInfoPage(VideoPageRequestVM requestVM) {
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "video_id desc").doSelectPageInfo(() ->
                videoInfoMapper.findVideoPage(requestVM)
        );
    }
}
